<?php
	

defined('_JEXEC') or die();

jimport( 'joomla.application.component.model' );


class NBEventMapsModelAuteur extends JModel
{

	function __construct()
	{
		parent::__construct();

		$mainframe = &JFactory::getApplication(); 
		$option    = JRequest::getCMD('option'); 
		$controller = JRequest::getWord('controller');

	}

	function getCid()
	{
		$cid = JRequest::getVar('cid',  0, '', 'array');
		$where 		= ( count( $cid ) ? ' WHERE id='. implode( ' OR id=', $cid ) : '' );

		
		$query = 'SELECT id, nom, userid'
			. ' FROM #__nbeventmap'
			. $where
			. ' ORDER BY nom';
		return $this->_getList( $query );
	}
	
	
	function store()
	{
		$data = JRequest::get( 'post' );
		$id = explode(',',@$data[cid]);
		$id = implode (' OR id =',$id);
        $db = JFactory::getDBO();
		$query = ' UPDATE #__nbeventmap'
			. ' SET userid='.@$data[users][0]
			. ' WHERE id ='.$id;
         $db->setQuery($query);
		 $db->query();

		return true;
	}

	function getListeUsers()
	{
		$query = 'SELECT id, name'
			. ' FROM #__users'
			. ' WHERE block = 0'
			. ' ORDER BY name';
		return $this->_getList( $query );
	}
}
